#!/bin/sh
#
# Run a simple backup but
#   create two volumes and set a short Volume duration on
#   the first so that it will be used, recycled.  Then
#   Bug #1032 indicates it will get a changer error when
#   loading the second volume. However, we cannot reproduce
#   this problem.
#
# This test uses an autochanger
#
TestName="vol-duration-changer"
JobName=VolDurationChanger
. scripts/functions

require_tape_drive
require_autochanger

scripts/cleanup
scripts/copy-2tape-confs
scripts/prepare-two-tapes

change_jobname NightlySave $JobName

# Directory to backup.
# This directory will be created by setup_data().
BackupDirectory="${tmp}/data"

# Use a tgz to setup data to be backed up.
# Data will be placed at "${tmp}/data/".
setup_data data/small.tgz

# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
echo "${BackupDirectory}" >${tmp}/file-list


start_test

cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out /dev/null
messages
@$out ${cwd}/tmp/log1.out
setdebug level=100 storage=tape
label storage=tape volume=TestVolume001 slot=$SLOT1 pool=Default drive=$DRIVE1
label storage=tape volume=TestVolume002 slot=$SLOT2 Pool=Default drive=$DRIVE1
update Volume=TestVolume001 VolUse=30
update Volume=TestVolume002 VolUse=30
run job=$JobName level=Full Storage=tape yes
@sleep 31
run job=$JobName level=Full Storage=tape yes
wait
messages
list volumes
@#
@# now do a restore
@#
@$out ${cwd}/tmp/log2.out
restore where=${cwd}/tmp/susan-restores select storage=tape
unmark *
mark *
done
yes
wait
messages
quit
END_OF_DATA

run_susan
check_for_zombie_jobs storage=tape
stop_susan

check_two_logs
check_restore_diff
end_test
